package com.lsc.www.day09.hm;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        dayTest();
    }

    public static void dayTest(){
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        while (bl){
            System.out.println("请输入年份");
            try {
                int year =  sc.nextInt();
                if (year<0){
                    System.out.println("输入的年份有误，重新输入年份！");
                    continue;
                }
                System.out.println("请输入月份");
                int mt = sc.nextInt();
                if (mt<0 || mt >12){
                    System.out.println("输入的月份有误，重新输入月份！");
                    continue;
                }
                int day = 0;
                switch (mt) {
                    case 1: case 3: case 5: case 7: case 8: case 10: case 12:
                        day = 31;
                        break;
                    case 2:
                        day=28;
                        break;
                    case 4: case 6: case 9: case 11:
                        day = 30;
                        break;
                }
                if (year % 4 == 0 & mt ==2) {
                    day = 29;
                }
                System.out.println(day);
                System.out.println("是否继续1是 0否");
                int i = sc.nextInt();
                if (i==0){
                    bl = false;
                }
            } catch (InputMismatchException ime) {
                System.out.println("请正确输入");
                dayTest();
            }
        }
    }
}
